<script setup >
import {ref} from "vue"
import Son from "./Son.vue"

const sonRef = ref();

const getSon = () => {

    // sonRef.value: 就是子组件实例（对象）
    // console.log("sonRef.value",sonRef.value);

    sonRef.value.toSon("hi，我是父亲");

    // sonRef.value.fn();

}


</script>

<template>
    <div>
        <h1>父子组件传值（用ref）组合式</h1>
        <h2>父组件</h2>
        <input type="button" value="获取子组件" @click="getSon">
        <hr/>
        <Son ref="sonRef" />
    </div>
</template>

<style lang="css" scoped>
    
</style>
